package com.hsjk.szwj.module.pay.enums;

import cn.hutool.core.util.ArrayUtil;
import com.hsjk.szwj.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/08/21 22:09
 **/
@AllArgsConstructor
@Getter
public enum MchInfoTypeEnum implements IntArrayValuable {
    ISV(1, "服务商"),
    MCH(2, "商户"),
    APP(3, "商户应用");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MchInfoTypeEnum::getType).toArray();

    /**
     * 类型
     */
    private final Integer type;
    /**
     * 类型名
     */
    private final String name;

    public static MchInfoTypeEnum valueOf(Integer type) {
        return ArrayUtil.firstMatch(userType -> userType.getType().equals(type), MchInfoTypeEnum.values());
    }

    @Override
    public int[] array() {
        return ARRAYS;
    }
}
